<%@page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>机构部门</title>
<%@ include file="/common/header/meta.jsp"%>
<%@ include file="/common/header/script.jsp"%>
<script type="text/javascript">
	var $t1, $t2 ;
	$(function() {
		$t1 = $("#t1").tree({
			url: base.contextPath+"/sysmgr/company/doNotNeedAuth_tree.do",
			method: "get",animate: true, lines: true, 
            onClick: function (node) {
            	
            	$.post(base.contextPath+"/sysmgr/company/doNotNeedAuth_totalMember.do", {id:node.id}, function(result) {
            		$("#company_info span[name=totalMember]").html((undefined==result.totalMember?"0  人":result.totalMember)+" 人") ;
				}, 'json').error(function(){}); 
            	
            	$.post(base.contextPath+"/sysmgr/company/doNotNeedAuth_get.do", {id:node.id}, function(result) {
            		if (result.id != undefined) {
            			$("#company_info span").html("");
            			$("#dept_info").hide() ;
            			$("#company_info").slideDown("slow");
            			$.each(result, function(name, val){
            				$("#company_info span[name="+name+"]").html(val) ;  
            			});
            		}
				}, 'json').error(function(){$.easyui.loaded("#centerPanel");});
            	
            	$("#t2").tree("load", base.contextPath+"/sysmgr/dept/doNotNeedAuth_tree.do?company_id="+node.id);
            },
            onLoadSuccess: function (node, data) {
            	$.easyui.loading({ msg: "正在加载...", locale: "#centerPanel" });
            	var node = $t1.tree("getRoot") ;
            	if(node) {
            		$t1.tree("select", node.target) ;
            		
            		$.post(base.contextPath+"/sysmgr/company/doNotNeedAuth_totalMember.do", {id:node.id}, function(result) {
            			$("#company_info span[name=totalMember]").html((undefined==result.totalMember?"0 人":result.totalMember)+" 人") ;
    				}, 'json').error(function(){});
            		
                	$.post(base.contextPath+"/sysmgr/company/doNotNeedAuth_get.do", {id:node.id}, function(result) {
                		if (result.id != undefined) {
                			$("#company_info span").html("");
                			$("#company_info").slideDown();
                			$.each(result, function(name, val){
                				$("#company_info span[name="+name+"]").html(val) ;
                			});
                		}
                		$.easyui.loaded("#centerPanel");
    				}, 'json').error(function(){$.easyui.loaded("#centerPanel");});
                	
                	$t2 = $("#t2").tree({
            			url: base.contextPath+"/sysmgr/dept/doNotNeedAuth_tree.do?company_id="+node.id,
            			method: "get",animate: true, lines: true, 
                        onClick: function (node) {
                        	$.easyui.loading({ msg: "正在加载...", locale: "#centerPanel" });
                        	$.post(base.contextPath+"/sysmgr/dept/doNotNeedAuth_get.do", {id:node.id}, function(result) {
                        		if (result.id != undefined) {
                        			$("#company_info span").html("");
                        			$("#dept_info span").html("");
    		                    	$("#company_info").hide();
    	                			$("#dept_info").slideDown() ;
                        			$.each(result, function(name, val){
                        				$("#dept_info span[name="+name+"]").html(val) ;
                        			});
                        		}
                        		$.easyui.loaded("#centerPanel");
            				}, 'json').error(function(){$.easyui.loaded("#centerPanel");});
                        }
            	    });
            	} else { $.easyui.loaded("#centerPanel"); }
            }
	    });
		
	});	
	
	function company_form_edit(form) {
		var form_url = base.contextPath+"/sysmgr/company/company_form.do" ;
		if("E" == form) {
			var node = $t1.tree('getSelected');
			if (node) {
				form_url = base.contextPath+"/sysmgr/company/company_form.do?id="+node.id ;
			} else {
				alertify.warning("请选择一条记录！");
				return ;
			}
		}
		var $d = $.easyui.showDialog({
			href: form_url,
			width: 750, height: base.getInnerDialogH(770).height,
            title: "表单", iniframe: false, topMost: true,
            enableApplyButton: false, enableCloseButton: false,  enableSaveButton: false,
            buttons : [ 
              { text : '保存', iconCls : 'ext_save', handler : function() { $.easyui.parent.submitForm($d, $t1) ; } },
              { text : '关闭', iconCls : 'ext_cancel', handler : function() { $d.dialog('destroy'); } } 
           	]
        });
	}
	
	function company_del() {
		var node = $t1.tree('getSelected'); 
		if(node){
			$.messager.confirm("您确定要进行该操作？", function (c) { 
				if(c) {
					$.post(base.contextPath+"/sysmgr/company/delete.do", {id:node.id}, function(result) {
						if (result.status) {
							$t1.tree('reload') ;
							alertify.success(result.msg);
						} else {
							alertify.warning(result.msg);
						}
					}, 'json');
				}
			});
		} else {
			alertify.warning("请选择一条记录！");
		}
	}
	
	function dept_form_edit(form) {
		var form_url = base.contextPath+"/sysmgr/dept/dept_form.do" ;
		if("E" == form) {
			var node = $t2.tree('getSelected');
			if (node) {
				form_url = base.contextPath+"/sysmgr/dept/dept_form.do?id="+node.id ;
			} else {
				alertify.warning("请选择一条记录！");
				return ;
			}
		}
		var $d = $.easyui.showDialog({
			href: form_url, width: 750, height: base.getInnerDialogH(770).height,
            title: "表单", iniframe: false, topMost: true,
            enableApplyButton: false, enableCloseButton: false,  enableSaveButton: false,
            buttons : [ 
              { text : '保存', iconCls : 'ext_save', handler : function() { $.easyui.parent.submitForm($d, $t2) ; } },
              { text : '关闭', iconCls : 'ext_cancel', handler : function() { $d.dialog('destroy'); } } 
           	]
        });
	}
	
	function dept_del() {
		var node = $t2.tree('getSelected'); 
		if(node){
			$.messager.confirm("您确定要进行该操作？", function (c) { 
				if(c) {
					$.post(base.contextPath+"/sysmgr/dept/delete.do", {id:node.id}, function(result) {
						if (result.status) {
							$t2.tree('reload') ;
							alertify.success(result.msg);
						} else {
							alertify.warning(result.msg);
						}
					}, 'json');
				}
			});
		} else {
			alertify.warning("请选择一条记录！");
		}
	}
</script>

</head>

<body style="padding: 0px; margin: 0px;">
	<div class="easyui-layout" data-options="fit: true">
		
		<div data-options="region: 'west', border: false, iconCls: 'icon-standard-map', split: true, minWidth: 260, maxWidth: 500" style="width: 260px; padding: 1px;">
			<div class="easyui-layout" data-options="fit: true">
				<div data-options="region: 'center', title: '单位', split: true, border: true" style="height: 331px;">
					<div class="easyui-layout" data-options="fit: true">
                        <div data-options="region: 'north', split: false, border: false" style="height: 33px;">
                            <div class="easyui-toolbar">
                                <a id="navMenu_Favo" onClick="company_form_edit('A');" class="easyui-linkbutton easyui-tooltip" title="新建" data-options="plain: true, iconCls: 'ext_add'">新建</a>
                                <a id="navMenu_Rename" onClick="company_form_edit('E');" class="easyui-linkbutton easyui-tooltip" title="编辑" data-options="plain: true, iconCls: 'ext_edit'">编辑</a>
                                <a id="navMenu_Rename" onClick="company_del();" class="easyui-linkbutton easyui-tooltip" title="删除" data-options="plain: true, iconCls: 'ext_remove'">删除</a>
                                <a id="navMenu_Rename" onClick="$t1.tree('reload');" class="easyui-linkbutton easyui-tooltip" title="刷新" data-options="plain: true, iconCls: 'ext_reload'">刷新</a>
                            </div>
                        </div>
                        <div data-options="region: 'center', border: false">
                            <ul id="t1" style="padding-top: 2px; padding-bottom: 2px;"></ul>
                        </div>
                    </div>
				</div>
				
				<div data-options="region: 'south', title: '部门', split: true, border: true, minHeight: 32, maxHeight: 370"  style="height: 370px;">
					<div class="easyui-layout" data-options="fit: true">
                        <div data-options="region: 'north', split: false, border: false" style="height: 33px;">
                            <div class="easyui-toolbar">
                                <a id="navMenu_Favo" onClick="dept_form_edit('A');" class="easyui-linkbutton easyui-tooltip" title="新建" data-options="plain: true, iconCls: 'ext_add'">新建</a>
                                <a id="navMenu_Rename" onClick="dept_form_edit('E');" class="easyui-linkbutton easyui-tooltip" title="编辑" data-options="plain: true, iconCls: 'ext_edit'">编辑</a>
                                <a id="navMenu_Rename" onClick="dept_del();" class="easyui-linkbutton easyui-tooltip" title="删除" data-options="plain: true, iconCls: 'ext_remove'">删除</a>
                                <a id="navMenu_Rename" onClick="$t2.tree('reload');" class="easyui-linkbutton easyui-tooltip" title="刷新" data-options="plain: true, iconCls: 'ext_reload'">刷新</a>
                            </div>
                        </div>
                        <div data-options="region: 'center', border: false">
                            <ul id="t2" style="padding-top: 2px; padding-bottom: 2px;"></ul>
                        </div>
                    </div>
				</div>
			</div>
		</div>
		
		<div id="centerPanel" data-options="region: 'center', border: false" style="padding: 1px;">
		
			<div id="company_info" class="tab_block">
				<table>
					<tr><th width="100">机构名称：</th><td><span name="name"></span></td></tr>
					<tr><th width="100">机构代码：</th><td><span name="code"></span></td></tr>
					<tr><th width="100">联系电话：</th><td><span name="tel"></span></td></tr>
					<tr><th width="100">传真号码：</th><td><span name="fax"></span></td></tr>
					<tr><th width="100">地区邮编：</th><td><span name="post_code"></span></td></tr>
					<tr><th width="100">所属地区：</th><td><span name="area"></span></td></tr>
					<tr><th width="100">联系地址：</th><td><span name="addr"></span></td></tr>
					<tr><th width="100">官方网址：</th><td><span name="site"></span></td></tr>
					<tr><th width="100">总人数：</th><td><span name="totalMember"></span></td></tr>
					<tr><td colspan="2"><span name="remark"></span></td></tr>
				</table>
			</div>
			
			<div id="dept_info" class="tab_block">
				<table>
					<tr><th width="100">部门名称：</th><td><span name="name"></span></td></tr>
					<tr><th width="100">部门主管：</th><td><span name=""></span></td></tr>
					<tr><th width="100">部门助理：</th><td><span name=""></span></td></tr>
					<tr><th width="100">分管领导：</th><td><span name=""></span></td></tr>
					<tr><th width="100">部门位置：</th><td><span name="position"></span></td></tr>
					<tr><th width="100">联系电话：</th><td><span name="tel"></span></td></tr>
					<tr><th width="100">传真号码：</th><td><span name="fax"></span></td></tr>
					<tr><th width="100">部门职能：</th><td><span name="duty"></span></td></tr>
					<tr><th width="100">年度目标：</th><td><span name="year_target"></span></td></tr>
					<tr><th width="100">工作计划：</th><td><span name="work_plan"></span></td></tr>
					<tr><th width="100">部门简介：</th><td><span name="remark"></span></td></tr>
				</table>
				
				<table style="margin-top:20px;">
					<tr><th width="100">总部门数：</th><td><span name=""></span></td></tr>
					<tr><th width="100">在职人员：</th><td><span name=""></span></td></tr>
					<tr><th width="100">离职人数：</th><td><span name=""></span></td></tr>
					<tr><th width="100">退休人数：</th><td><span name=""></span></td></tr>
				</table>
				
				
			</div>
		</div>
	</div>	
</body>
</html>